﻿namespace Aliphant.Interfaces
{
    public interface IDiContainer : IDisposable
    {
        /// <summary>
        /// 注册单例服务（接口+实现）
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <typeparam name="TImplementation"></typeparam>
        void AddSingleton<TService, TImplementation>() where TImplementation : TService;

        void AddSingleton<TService, TImplementation>(string name) where TImplementation : TService;

        /// <summary>
        /// 注册单例服务（直接实例）
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <param name="instance"></param>
        public void AddSingleton<TService>(TService instance);

        public void AddSingleton<TService>(string name, TService instance);

        /// <summary>
        /// 注册区域服务
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <typeparam name="TImplementation"></typeparam>
        public void AddScoped<TService, TImplementation>() where TImplementation : TService;

        public void AddScoped<TService, TImplementation>(string name) where TImplementation : TService;

        /// <summary>
        /// 注册模块
        /// </summary>
        /// <typeparam name="TModule"></typeparam>
        public void AddModule<TModule>() where TModule : IModule, new();

        /// <summary>
        /// 解析服务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Resolve<T>();

        public T Resolve<T>(string name);


    }
}
